home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SPACE 2
/
SPACE - Library 2 - Volume 1.iso
/
apps
/
255
/
applic
/
sorter.doc
< prev
next >
Wrap
Text File
|
1988-06-14
|
5KB
|
92 lines
SORTER.TOS HELP FILE
SORTER.TOS can sort a file of up to 8000 entries on up to 9 keys at once.
Sorts can be made alphabetically or numerically in increasing or decreasing
order, and duplicate entries can be eliminated during the sort process.
Each entry may consist of any number of lines of up to 250 characters
length each, and the lines don't need to be of the same length. The
sort is based on data in the first line only, and the data must be in the
same columns for each entry.
SORTER.TOS performs a multiple level sort, so that you can give different
priorities to different key fields. For example, suppose you wanted to
sort the GEnie directory of programs that you have stored on disk, sorted
by library, and within each library alphabetically by the uploading author,
and finally reverse numerically by file number for each author. You would
be prompted first for the file name (you can specify a path to any disk or
folder) and then asked for the number of lines per entry (in this case 2).
You will be reminded briefly of the instructions, and the first line of the
file will be listed with a set of numbers to help identify the correct
column. You would then specify the sorting keys as follows:
10 20 30 40 50 60 70
123456789 123456789 123456789 123456789 123456789 123456789 123456789 1234
5479 UNI20.ARC (UNITERM 2.0) X R-FLASHMAN 880110 141120 23 7
Enter key 1: 70 71 a i
Enter key 2: 34 46 a i
Enter key 3: 1 5 n d
Enter key 4:
Key 1 says to sort on columns 70 to 71 (library number) in alphabetic
order. (Note that most of the time alpha/ASCII order is the same as
numeric order.) Key 2 does an alphabetic sort on the data in columns
34 through 46, and Key 3 does a numeric, decreasing sort on columns 1
through 5. (Note again that an alpha sort would have sufficed here.)
The priority of each key is based on the order of its entry, so that
everything is sorted on key 1 first, then key 2, and then key 3. A blank
line indicates that you're ready to start sorting.
The available options in the sort operation are:
I - sort in increasing or D - decreasing order
A - sort by alpha/ASCII or N - numeric/float order
Z - treat blanks as zero for numeric sorts
E - eliminate entries with all identical keys
The default (when no options are given) is in increasing (I) alpha/ASCII
(A) order. If nothing is specified, the first ten columns are used.
The Z option is useful only in peculiar circumstances, and can result
in unexpected sorting orders. (I use it for astronomical catalogs that
have zero coordinates omitted.) The E option will remove any duplicate
entries, HOWEVER DUPLICATES ARE DETERMINED BY THE KEYSTRINGS ONLY, so that
even when the rest of the entry is different, if all the keys are the same,
the E option will still eliminate the duplicate. It is unpredictable
which duplicate will be eliminated. The E option need be specified only
once since all keys will be examined before any entry is deleted.
After the sort is completed, you will be prompted for the output file name.
You can swap disks at this point, or even overwrite the input file (this
is NOT recommended, especially if you've used option E, unless the data is
expendable).
HINTS AND COMMENTS
SORTER.TOS is based on a Heap-sort algorithm which is nearly as fast as a
Quick-sort, and has none of the potential problems. (Quick-sort becomes
extremely slow in cases where the data is nearly in order already, which
may be the case with a frequently sorted database.)
All the data is read into memory along with encoded key strings, and the
sort is performed using pointers. For large files, you may want to boot
up your computer with no accessories present.
The numeric sort will read in any integer or floating point format. Since
single precision is used, 4 bytes are used to store the key string no
matter how big or small the number is. Thus, it is recommended that the
numeric sort be used for numeric fields that are longer than 4 bytes to
use up less memory for the key string.
I have used SORTER successfully on a large number of files, but of course
I cannot guarantee it will work for everyone. I WILL be happy to modify
the program if you have a particular need or problem. The program seems
to be fairly slow during the reading and writing operations on large files.
If anyone knows how I can speed this up, I would appreciate the info. (The
program was written with Megamax C.)
To contact me on GEnie, my mail name is SESCHNEIDER.
Good luck!
Steve Schneider